package com.netease.nie.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.utils.CopyUtils;
import com.netease.nie.common.CommonService;
import com.netease.nie.dao.TopicDao;
import com.netease.nie.model.Topic;
import com.netease.nie.model.TopicDto;

@Service
public class TopicServiceImpl extends CommonService implements TopicService {

	@Autowired
	private TopicDao topicDao;
	
	public List<TopicDto> queryAllTopicDtos() {
		List<Topic> topicList = topicDao.queryAllTopics();
		List<TopicDto> topicDtoList = generateTopicDtos(topicList);
		return topicDtoList;
	}

	public TopicDto queryTopicDtoByTopicId(int topicId) {
		Topic topic = topicDao.queryTopicById(topicId);
		TopicDto topicDto = new TopicDto();
		if (topic != null)
			CopyUtils.copy(topicDto, topic);
		return topicDto;
	}

}
